﻿@using Gtkj.CMS.Model
@model Order
@{
    ViewBag.Title = "修改订单 ";
    Layout = "~/Views/Shared/Master.cshtml";

}

<div class="page-content-wrapper">
    <!-- BEGIN CONTENT BODY -->
    <div class="page-content">
        <!-- BEGIN PAGE HEADER-->
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li>
                    <a href="/Home/Main">首页</a>
                    <i class="fa fa-angle-double-right"></i>
                </li>
                <li>
                    <span>修改订单</span>
                </li>
            </ul>
        </div>
        <h3 class="page-title">
            修改订单<span><a class="btn btn-success " href="javascript:;" onclick="history.go(-1);"><span class="icon-action-undo" aria-hidden="true" style="float:left; margin-top:3px; margin-right:4px"></span> 返回</a></span>
        </h3>
        <!-- BEGIN PAGE TITLE-->
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption"><i class="icon-settings font-yellow-casablanca"></i><span class="caption-subject bold font-yellow-casablanca">修改订单信息</span></div>
            </div>
            <!--添加代码开始-->
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <form action="#" id="AddOrderForm" method="post" class="form-horizontal layui-form">
                    @Html.HiddenFor(e => e.Id)
                    @Html.HiddenFor(e => e.CreateUserId)
                    @Html.HiddenFor(e => e.CreateTime)
                    @Html.HiddenFor(e => e.CustomerId)
                    <div class="form-body">

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户名称<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="CustomerName" id="CustomerName" value="@Model.CustomerName" data-required="1" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户手机号<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Phone" id="Phone" data-required="1" value="@Model.Phone" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                性别<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                @Html.CheckBoxFor(e => e.Sex, new { @data_size = "small", @id = "Sex", @class = "make-switch", @data_on_text = "男", data_off_text = "女" })
                                @*<input type="checkbox" data-size="small" name="Sex" id="Sex" class="make-switch" checked data-on-text="男" data-off-text="女">*@
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                年龄<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Age" data-required="1" id="Age" value="@Model.Age" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                服务人员<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="ByName" data-required="1" id="ByName" value="@Model.ByName" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        @if (((AdminInfo)ViewData["User"]).IsAdmin == true)
                        {
                            <div class="form-group">
                                <label class="control-label col-md-3">
                                    快递单号<span class="required"> &nbsp; </span>
                                </label>
                                <div class="col-md-4">
                                    <input type="text" name="ExpressNumber" data-required="1" id="ExpressNumber" value="@Model.ExpressNumber" lay-verify="" class="form-control" />
                                </div>
                            </div>
                        }
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户地址<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Address" data-required="1" id="Address" value="@Model.Address" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户等级<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <select class="bs-select form-control" id="Stars" name="Stars" data-width="125px" style="display:block;">
                                    <option value="暂无">请选择</option>
                                    <option value="一级">一级</option>
                                    <option value="二级">二级</option>
                                    <option value="三级">三级</option>
                                    <option value="四级">四级</option>
                                    <option value="五级">五级</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                产品名称<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="GoodName" data-required="1" id="GoodName" value="@Model.GoodName" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                订购微信<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="ByWeChat" data-required="1" id="ByWeChat" value="@Model.ByWeChat" lay-verify="required" class="form-control" />
                            </div>
                        </div>

                        @*<div class="form-group">
                                <label class="control-label col-md-3">
                                    支付方式<span class="required"> * </span>
                                </label>
                                <div class="col-md-4">
                                    <input type="text" name="PayWay" lay-verify="required" id="PayWay" value="@Model.PayWay" class="form-control" />
                                </div>
                            </div>*@


                        <div class="form-group">
                            <label class="control-label col-md-3">
                                支付方式<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <select class="bs-select form-control" id="PayWay" name="PayWay" data-width="125px" style="display:block;">
                                    <option>支付宝支付</option>
                                    <option>微信支付</option>
                                    <option>货到付款</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                回访时间<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="VisitTime" id="VisitTime" data-required="1" value="@Model.VisitTime.ToString(" yyyy-MM-dd")" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                价格<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Price" lay-verify="required|number" id="Price" value="@Model.Price" class="form-control" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                详情
                            </label>
                            <div class="col-md-4">
                                <textarea id="Details" name="Details" class="form-control" placeholder="输入详情 ..." rows="4">@Model.Details</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                图片1
                            </label>
                            <div class="col-md-4">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn ImageUp" name="UpOne">上传图片</button>
                                    <input type="hidden" id="UpOne" name="Image1" value="@Model.Image1" />
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" style="width:316px;height:180px;" src="@Model.Image1" id="pwUpOne">
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                图片2
                            </label>
                            <div class="col-md-4">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn ImageUp" name="UpTwo">上传图片</button>
                                    <input type="hidden" id="UpTwo" name="Image2" value="@Model.Image2" />
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" style="width:316px;height:180px;" src="@Model.Image2" id="pwUpTwo">
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                图片3
                            </label>
                            <div class="col-md-4">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn ImageUp" name="UpThree">上传图片</button>
                                    <input type="hidden" id="UpThree" name="Image3" value="@Model.Image3" />
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" style="width:316px;height:180px;" src="@Model.Image3" id="pwUpThree">
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                @*<a href="#" class="btn btn-primary"> <span class="glyphicon glyphicon-ok"> </span> 提交 </a>*@
                                <button type="button" lay-submit class="btn btn-primary" onclick="AddOrderOn();"><span class="glyphicon glyphicon-ok"> </span> 提交</button>
                                <button type="button" class="btn default" onclick="history.go(-1);"><span class="glyphicon glyphicon-remove"> </span> 取消</button>
                            </div>
                        </div>
                    </div>
                </form>
                <!-- END FORM-->
            </div>
        </div>
        <!--添加代码结束-->
    </div>
</div>
<script>
    var imgnum;
    layui.use('laydate', function () {
        var laydate = layui.laydate, upload = layui.upload;

        var uploadInst = upload.render({
            elem: '.ImageUp'
            , url: '/Home/UploadPic'
            , before: function (obj) {
                var item = this.item;
                imgnum = $(item).attr("name");

                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#pw' + imgnum).attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("#" + imgnum).val(res.data);
            }
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#VisitTime' //指定元素
        });
    });

    $(function () {
        var selected = "@Model.PayWay";
        $("#PayWay option").each(function (index, item) {
            if ($(item).text() == selected) {
                $(item).attr("selected","selected");
            }
        });
       var selected2 = "@Model.Stars";
       $("#Stars option").each(function (index, item) {
           if ($(item).text() == selected2) {
                $(item).attr("selected","selected");
            }
        });
    });

    function AddOrderOn() {
        $.ajax({
            url: "/Home/AddOrderOn",
            type: "post",
            data: $("#AddOrderForm").serialize() + "&Sex=" + $("#Sex").is(':checked'),
            success: function (result) {
                if (result.success) {
                    history.go(-1);
                } else {
                    if (!result.requied) {
                        layer.msg(result.msg);
                    }
                }
            }
        });
    }
</script>
